/* $RCSFile: GtwBase.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/AddonNice.ECommerce.BankGateway/GtwBase.cs $
 * $log$
 * Revision 8 2010/08/09 10:07:05  christian.surieux
 *   Added Log comment to all cs files
 */

using System;
using System.Diagnostics;
using System.Configuration;
using System.Data;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;

using AddonNice.Diagnostics;

namespace AddonNice.ECommerce.Gateways
{

    /// <summary>
	/// GtwBase is an abstract class which include only necessary properties to manage all gateway types: payment, shipping, security.
	/// </summary>
	public abstract class GtwBase
	{
        #region TraceSwitch for Gtw2
	    static protected ADNTraceSwitch	Gtw2TraceSwitch	=	new ADNTraceSwitch("Gtw2Trace","Trace Switch for Gtw2 DLL");
	    #endregion TraceSwitch for Gtw2

        /// <summary>
		/// Gateway manager can instantiate the class using this name.
		/// </summary>
		public abstract string Name
		{
			get;
		}
        /// <summary>
        /// This is the key for storing Gateway data used by GatewaysDataLoader
        /// </summary>
		public abstract Guid MerchantID
		{
			get;
			set;
		}

		/// <summary>
		/// Custom Settings
		/// </summary>
		public abstract NameValueCollection CustomSettings
		{
			get;
		}

		// Must be assigned when the gateway is loaded		
		string	_ApplicationPhysicalPath	    =	string.Empty;
		public string ApplicationPhysicalPath 
		{
			get 
			{
				return _ApplicationPhysicalPath ;
			}
			set 
			{
				if ( value != null )
					_ApplicationPhysicalPath	=	value;
			}
		}

		/// <summary>
		/// Purpose: Property to access the GatewayName field.
		/// </summary>
		private string	_GatewayName					=	string.Empty;
		public string GatewayName 
		{
			get 
			{
				return _GatewayName;
			}
			set 
			{
				if ( value == null )
					value	=	string.Empty;
				_GatewayName = value;
			}
		}

        public string this[string key]
		{
			get 
			{
				object ob	=	CustomSettings[key];
				if ( ob != null )
					return (string)ob;
				if ( Gtw2TraceSwitch.TraceVerbose)
                    Trace.WriteLine( string.Format(CultureInfo.InvariantCulture,"[V]PaymentGtwBase value not found in customsettings Key: '{0}'",key),Gtw2TraceSwitch.Info);
				return string.Empty;
			}
			set
			{
				if ( value != null )
					CustomSettings[key]	=	value;
			}
		}

	}
}